#include<iostream>
#include<signal.h>
#include<sys/types.h>
#include<unistd.h>
void handler(int sig)
{
    std::cout<<"sig:"<<sig<<std::endl;
}

void PendingPritf(sigset_t& pending)
{
    printf("我的pid=%d,pending:",getpid());
    for(int i=32;i>=1;i--)
    {
        if(sigismember(&pending,i))
        {
            std::cout<<"1";
        }
        else{
            std::cout<<"0";
        }
    }
    std::cout<<std::endl;
    
}

int main()
{
    signal(SIGINT,handler);
    sigset_t block,oblock;
    sigemptyset(&block);
    sigemptyset(&oblock);
    sigaddset(&block,SIGINT);
    int n = sigprocmask(SIG_SETMASK,&block,&oblock);
    if(n<0)
    {
        std::cout<<"error"<<std::endl;
    }
    while(true)
    {
        sigset_t pending;
        int m = sigpending(&pending);
        PendingPritf(pending);
        
    }


    return 0;
}